"""
看了评论发现还有O(1)的算法
"""


class Solution:
    def clumsy(self, N: int) -> int:
        if N == 1:
            return 1
        elif N == 2:
            return 2
        elif N == 3:
            return 6
        elif N == 4:
            return 7
        else:
            s = (lambda x: x + 2, lambda x: x + 2, lambda x: x - 1, lambda x: x + 1)
            return s[N % 4 - 1](N)


if __name__ == "__main__":
    for i in range(1, 50):
        print(i, Solution().clumsy(i))
